﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SmartCity.ProcessEngine.API.Read.Application.Commands.FormDetail;
using SmartCity.ProcessEngine.API.Read.Application.Commands.FormNode;
using SmartCity.ProcessEngine.API.Read.Application.Commands.Forms;
using SmartCity.ProcessEngine.API.Read.Application.Commands.FormTypes;
using SmartCity.ProcessEngine.API.Read.Application.Commands.Settings;
using SmartCity.ProcessEngine.API.Read.DTO;
using SmartCity.ProcessEngine.Errorcode;

namespace SmartCity.ProcessEngine.API.Read.Controllers
{
    /// <summary>
    /// ProcessEngine API 控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ManagementController : ControllerBase
    {
        private readonly IMediator mediator;

        public ManagementController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 获取表单分类列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<ApiPaging<FormTypeDto>>> GetFormType([FromQuery]FormTypeQueryCommand request)
        {
            return mediator.Send(request);
        }

        /// <summary>
        /// 获取行业列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<IndustryDto>>> GetIndustry()
        {
            return mediator.Send(new IndustryQueryCommand());
        }
        /// <summary>
        /// 获取表单列表
        /// </summary>
        /// <param name="request">命令</param>
        /// <returns>返回表单列表任务</returns>
        [HttpGet]
        public Task<ApiResult<List<FormDto>>> FormQuery([FromQuery]FormQueryCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 获取表单列表(下拉框)
        /// </summary>
        /// <param name="request">命令</param>
        /// <returns>返回表单列表</returns>
        [HttpGet]
        public Task<ApiResult<List<FormTypeDto>>> FormTypeCascader([FromQuery]FormTypeCascaderQueryCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 获取表单明细列表
        /// </summary>
        /// <param name="request">命令</param>
        /// <returns>返回表单明细列表</returns>
        [HttpGet]
        public Task<ApiResult<List<FormDetailDto>>> FormDetailQuery([FromQuery]FormDetailQueryCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 获取节点列表
        /// </summary>
        /// <param name="request">命令</param>
        /// <returns>返回节点列表</returns>
        [HttpGet]
        public Task<ApiResult<List<FormNodeDto>>> GetNode([FromQuery]NodeQueryCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 获取表单列表
        /// </summary>
        /// <param name="request">命令</param>
        /// <returns>返回表单列表任务</returns>
        [HttpGet]
        public Task<ApiResult<List<FormDto>>> FormCascader([FromQuery]FormCascaderCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 获取流程设置列表
        /// </summary>
        /// <param name="request">命令</param>
        /// <returns>返回流程列表任务</returns>
        [HttpGet]
        public Task<ApiResult<ApiPaging<SettingDto>>> GetSetting([FromQuery]GetSettingCommand request)
        {
            return mediator.Send(request);
        }
    }
}
